package com.example.rabbitmq.sender;

import com.example.rabbitmq.bean.User;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Copyright(C), 2020-2021, AmbroseCdMeng
 * FileName:    ObjectSender
 * Author:      AmbroseCdMeng
 * Date:        2021/3/2 9:35
 * Description: 发送类。实现发送和接收对象
 * History:
 * <author>     <time>      <version>       <desc>
 * 作者姓名     修改时间        版本号           描述
 */
@Component
public class ObjectSender {
    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send(User user) {
        System.out.println("Sender object: " + user.toString());
        this.amqpTemplate.convertAndSend("object", user);
    }
}
